
layui.use('element', function(){
    var $ = layui.jquery
        ,element = layui.element;

    $('.menus').on('click', function(){
        var ele = $(this);
        var id = ele.attr("data-id");
        var href = ele.attr("data-href");
        var title = ele.attr("data-title");
        //判断存不存在
        var isExit = $("li[lay-id="+id+"]");
        //元素集合>0 就存在 直接切换
        if(isExit.length>0){
            //切换
            element.tabChange('main_body', id);
        }else{
            element.tabAdd("main_body",{
                title:title,
                content:"<iframe src='"+href+"' frameborder=\"0\"style=\"width: 100%; height: 600px;\"></iframe>",
                id:id
            });
            element.tabChange('main_body', id);
        }
    });
});